package com.younion.action.manage;

import java.util.List;
import java.util.Map;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;

import com.younion.business.IOperateLogService;
import com.younion.common.base.BaseAction;
import com.younion.common.paginator.Paginator;
import com.younion.vo.OperateLogVO;
import com.younion.vo.UserVO;

import cpcns.jhsks.util.MapCollectionUtils;

public class OperateLogAction extends BaseAction {

	protected static final Log logger = LogFactory.getLog(OperateLogAction.class);

	private OperateLogVO operateLogVO = new OperateLogVO();

	private List<OperateLogVO> operateLogList;

	/**
	 * 列表：翻页区；数据区
	 */
	@RequiresPermissions("listLog")
	public String listLog() {
		try {
			this.addLog(2, "查询日志", "查询日志", this.getSessionUser());
			Map paramMap = null;
			if (operateLogVO != null) {
				paramMap = MapCollectionUtils.removeEmptyEntry(PropertyUtils.describe(operateLogVO));
			}
			// 获取总记录数
			int total = this.operateLogService.getCountByMap(paramMap);
			// 根据总记录数获取分页对象
			Paginator paginator = this.getPaginator(total);
			this.operateLogList = this.operateLogService.get(paramMap, paginator);
			// 保存分页对象
			this.savaPaginator(paginator);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
		}
		return SUCCESS;
	}

	public OperateLogVO getOperateLogVO() {
		return this.operateLogVO;
	}

	public void setOperateLogVO(OperateLogVO operateLogVO) {
		this.operateLogVO = operateLogVO;
	}

	public List<OperateLogVO> getOperateLogList() {
		return this.operateLogList;
	}

	public void setOperateLogList(List<OperateLogVO> operateLogList) {
		this.operateLogList = operateLogList;
	}

}